package com.example.springboot.service;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.springboot.entity.*;
import com.example.springboot.mapper.McDustMapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class DustService {
    @Autowired
    private McDustMapper mcDustMapper;

    // 媒尘
    public PageInfo<McDust> selectAllMc(int pageNum, int pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        List<McDust> Mclist = mcDustMapper.selectAllMc();
        return new PageInfo<>(Mclist);
    }

    // 水泥
    public PageInfo<McDust> selectAllSn(int pageNum, int pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        List<McDust> Snlist = mcDustMapper.selectAllSn();
        return new PageInfo<>(Snlist);
    }

    // 矽尘
    public PageInfo<McDust> selectAllXc(int pageNum, int pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        List<McDust> Xclist = mcDustMapper.selectAllXc();
        return new PageInfo<>(Xclist);
    }

    // 所有粉尘
    public PageInfo<McDust> selectAllDust(int pageNum, int pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        List<McDust> AllDustlist = mcDustMapper.selectAllDust();
        return new PageInfo<>(AllDustlist);
    }

    //    按地点查询媒尘数据
    public PageInfo<McDust> selectMcByPlace(int pageNum, int pageSize ,String place) {
        PageHelper.startPage(pageNum, pageSize);
        List<McDust> McByCityList = mcDustMapper.selectMcByCity(place);
        return new PageInfo<>(McByCityList);
    }

    //    按地点查询水泥数据
    public PageInfo<McDust> selectSnByPlace(int pageNum, int pageSize ,String place) {
        PageHelper.startPage(pageNum, pageSize);
        List<McDust> SnByCityList = mcDustMapper.selectSnByCity(place);
        return new PageInfo<>(SnByCityList);
    }

    //    按地点查询矽尘数据
    public PageInfo<McDust> selectXcByPlace(int pageNum, int pageSize ,String place) {
        PageHelper.startPage(pageNum, pageSize);
        List<McDust> XcByCityList = mcDustMapper.selectXcByCity(place);
        return new PageInfo<>(XcByCityList);
    }

    //  查询出某几年的媒尘数据
    public PageInfo<McDust> selectMcByYear(int pageNum, int pageSize ,int year ,String city_name) {
        PageHelper.startPage(pageNum, pageSize);
        List<McDust> McByYearList = mcDustMapper.selectMcByYear(year,city_name);
        return new PageInfo<>(McByYearList);
    }

    //  查询出某几年的水泥数据
    public PageInfo<McDust> selectSnByYear(int pageNum, int pageSize ,int year ,String city_name) {
        PageHelper.startPage(pageNum, pageSize);
        List<McDust> SnByYearList = mcDustMapper.selectSnByYear(year,city_name);
        return new PageInfo<>(SnByYearList);
    }

    //  查询出某几年的矽尘数据
    public PageInfo<McDust> selectXcByYear(int pageNum, int pageSize ,int year ,String city_name) {
        PageHelper.startPage(pageNum, pageSize);
        List<McDust> XcByYearList = mcDustMapper.selectXcByYear(year,city_name);
        return new PageInfo<>(XcByYearList);
    }

    //    查询某一年的媒尘数据
    public PageInfo<McDust> selectMcDustByYear(int pageNum, int pageSize, int year) {
        PageHelper.startPage(pageNum, pageSize);
        List<McDust> McDustByYearList = mcDustMapper.selectMcDustByYear(year);
        return new PageInfo<>(McDustByYearList);
    }

    //    查询某一年的水泥数据
    public PageInfo<McDust> selectSnDustByYear(int pageNum, int pageSize, int year) {
        PageHelper.startPage(pageNum, pageSize);
        List<McDust> SnDustByYearList = mcDustMapper.selectSnDustByYear(year);
        return new PageInfo<>(SnDustByYearList);
    }

    //    查询某一年的媒尘数据
    public PageInfo<McDust> selectXcDustByYear(int pageNum, int pageSize, int year) {
        PageHelper.startPage(pageNum, pageSize);
        List<McDust> XcDustByYearList = mcDustMapper.selectXcDustByYear(year);
        return new PageInfo<>(XcDustByYearList);
    }

    //    查询华昊体检数据
    public PageInfo<PhysicalExamination> selectAllHh(int pageNum, int pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        List<PhysicalExamination> Hhlist = mcDustMapper.selectAllHh();
        return new PageInfo<>(Hhlist);
    }

    //    查询大众体检数据
    public PageInfo<PhysicalNxdz> selectAllDz(int pageNum, int pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        List<PhysicalNxdz> Dzlist = mcDustMapper.selectAllDz();
        return new PageInfo<>(Dzlist);
    }

    //    查询青龙体检数据
    public PageInfo<PhysicalQinglong> selectAllQingLong(int pageNum, int pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        List<PhysicalQinglong> QingLonglist = mcDustMapper.selectAllQingLong();
        return new PageInfo<>(QingLonglist);
    }

    //    查询银川栏劫体检数据
    public PageInfo<PhysicalYclanjie> selectAllYinchuan(int pageNum, int pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        List<PhysicalYclanjie> Yinchuanlist = mcDustMapper.selectAllYinchuan();
        return new PageInfo<>(Yinchuanlist);
    }


    //    查询一品生物体检数据
    public PageInfo<PhysicalYiping> selectAllYpsw(int pageNum, int pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        List<PhysicalYiping> Ypswlist = mcDustMapper.selectAllYpsw();
        return new PageInfo<>(Ypswlist);
    }


//    查询所有数据模糊查询

//    public Page<McDust> selectAllDustWithConditions(int pageNum, int pageSize, Map<String, Object> conditions) {
//        // 定义要查询的表
//        List<String> tables = List.of("mc_2020", "mc_2021", "mc_2022", "mc_2023",
//                "sn_2020", "sn_2021", "sn_2022", "sn_2023",
//                "xc_2020", "xc_2021", "xc_2022", "xc_2023");
//
//        // 创建 Page 对象
//        Page<McDust> page = new Page<>(pageNum, pageSize);
//
//        // 调用 Mapper 方法
//        Page<McDust> result = mcDustMapper.selectAllDustWithConditions(page, tables, conditions);
//
//        // 返回 Page 对象
//        return result;
//    }
}
